package com.itheima.wisdomnext.mapper;

import com.itheima.wisdomnext.entity.QaPost;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface QATextAnswerMapper {

    // 插入自由回答
    @Insert("INSERT INTO qa_text_answers (question_id, answer_userid, answer_content, created_at) " +
            "VALUES (#{qaPost.id}, #{qaPost.questionUserId}, #{qaPost.questionTitle}, NOW())")
    int insertAnswer(@Param("qaPost") QaPost qaPost);

    // 插入选项式回答
    @Insert("INSERT INTO qa_choice_answers (question_id, option_id, answer_userid, created_at) " +
            "VALUES (#{questionId}, #{optionId}, #{answerUserId}, NOW())")
    int insertChoiceAnswer(@Param("questionId") Integer questionId,
                           @Param("answerUserId") Integer answerUserId,
                           @Param("optionId") Integer optionId);
}
